<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>项目详情 - 我的作品集</title>
    <style>
        /* 基础重置和全局样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Helvetica Neue', Arial, sans-serif;
            background: #1a1a1a;
            color: #fff;
        }

        /* 导航栏基础样式 */
        .navbar {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 80px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 40px;
            background: rgba(0, 0, 0, 0.8);
            backdrop-filter: blur(10px);
            z-index: 1000;
        }

        .logo a {
            color: #fff;
            text-decoration: none;
            font-size: 1.5rem;
            font-weight: 300;
            letter-spacing: 3px;
        }

        .nav-right {
            display: flex;
            align-items: center;
            gap: 30px;
        }

        .projects-link {
            color: #fff;
            text-decoration: none;
            font-size: 1rem;
            letter-spacing: 2px;
            padding: 8px 20px;
            border: 1px solid rgba(255, 255, 255, 0.3);
            border-radius: 20px;
            transition: all 0.3s ease;
        }

        .projects-link:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.5);
        }

        /* 菜单按钮样式 */
        .menu-button {
            width: 30px;
            height: 24px;
            background: none;
            border: none;
            padding: 0;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            cursor: pointer;
        }

        .menu-line {
            width: 100%;
            height: 2px;
            background-color: #fff;
            transition: transform 0.3s ease, opacity 0.3s ease;
        }

        .menu-button.active .menu-line:nth-child(1) {
            transform: translateY(11px) rotate(45deg);
        }

        .menu-button.active .menu-line:nth-child(2) {
            opacity: 0;
        }

        .menu-button.active .menu-line:nth-child(3) {
            transform: translateY(-11px) rotate(-45deg);
        }

        /* 菜单面板样式 */
        .menu-panel {
            position: fixed;
            top: 0;
            right: -100%;
            width: 100%;
            height: 100vh;
            background: rgba(0, 0, 0, 0.95);
            backdrop-filter: blur(10px);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            transition: right 0.5s ease;
            z-index: 999;
        }

        .menu-panel.active {
            right: 0;
        }

        .menu-panel a {
            color: #fff;
            text-decoration: none;
            font-size: 2rem;
            margin: 20px 0;
            position: relative;
            opacity: 0;
            transform: translateY(20px);
            transition: opacity 0.3s ease, transform 0.3s ease;
        }

        .menu-panel.active a {
            opacity: 1;
            transform: translateY(0);
        }

        .menu-panel a::after {
            content: '';
            position: absolute;
            bottom: -5px;
            left: 0;
            width: 0;
            height: 2px;
            background: #fff;
            transition: width 0.3s ease;
        }

        .menu-panel a:hover::after {
            width: 100%;
        }

        @media (max-width: 768px) {
            .navbar {
                padding: 0 20px;
            }

            .logo a {
                font-size: 1.2rem;
            }

            .nav-right {
                gap: 20px;
            }

            .projects-link {
                font-size: 0.9rem;
                padding: 6px 15px;
            }

            .menu-button {
                width: 24px;
                height: 20px;
            }
        }
    </style>
    <link rel="stylesheet" href="css/work-detail.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">

</head>
<body>
    <nav class="navbar">
        <div class="logo">
            <a href="index.html">PORTFOLIO</a>
        </div>
        <div class="nav-right">
            <a href="projects.html" class="projects-link">项目列表</a>
            <button class="menu-button" onclick="toggleMenu()">
                <span class="menu-line"></span>
                <span class="menu-line"></span>
                <span class="menu-line"></span>
            </button>
        </div>
    </nav>

    <div class="menu-panel">
        <!-- 菜单面板内容将通过JavaScript动态生成 -->
    </div>

    <div id="project-detail" class="work-detail">
        <!-- 项目详情将通过JavaScript动态生成 -->
    </div>

    <div class="work-navigation">
        <div id="prev-project" class="work-nav-item">
            <!-- 上一个项目将通过JavaScript动态生成 -->
        </div>
        <div id="next-project" class="work-nav-item">
            <!-- 下一个项目将通过JavaScript动态生成 -->
        </div>
    </div>

    <!-- 添加 jQuery 和 lightbox JS -->

    <script src="js/projectsData.js"></script>
    <script>
        function toggleMenu() {
            const menuPanel = document.querySelector('.menu-panel');
            const menuButton = document.querySelector('.menu-button');
            menuPanel.classList.toggle('active');
            menuButton.classList.toggle('active');

            // 如果菜单是空的，添加菜单项
            if (menuPanel.children.length === 0) {
                menuPanel.innerHTML = `
                    <a href="index.html">首页</a>
                    <a href="projects.html">项目</a>
                    <a href="about.html">关于</a>
                    <a href="contact.html">联系</a>
                `;
            }
        }

        function getProjectById(id) {
            return projects.find(p => p.id === id);
        }

        function getProjectIndex(id) {
            return projects.findIndex(p => p.id === id);
        }

        function createProjectDetail() {
            const urlParams = new URLSearchParams(window.location.search);
            const projectId = parseInt(urlParams.get('id'));
            const project = getProjectById(projectId);
            
            if (!project) {
                // 如果项目未找到，跳转到第一个项目
                const firstProject = projects[0];
                if (firstProject) {
                    window.location.href = `project-detail.html?id=${firstProject.id}`;
                    return;
                }
            }

            // 更新页面标题
            document.title = `${project.title} - 项目详情`;

            // 创建项目详情内容
            const detailContainer = document.getElementById('project-detail');
            detailContainer.innerHTML = `
                <div class="work-header">
                    <h1 class="work-title">${project.title}</h1>
                    <div class="work-tags">
                        ${project.tags.map(tag => `<span class="work-tag">${tag}</span>`).join('')}
                    </div>
                    <div class="work-description">
                        <p>${project.description}</p>
                    </div>
                </div>
                <div class="work-gallery">
                    ${project.detailImages.map((img, index) => `
                        <img 
                            src="./${img}" 
                            alt="${project.title} - 图片 ${index + 1}"
                            loading="lazy"
                            onload="this.classList.add('loaded')"
                        >
                    `).join('')}
                </div>
            `;

            // 创建导航链接
            const currentIndex = getProjectIndex(projectId);
            const prevProject = projects[currentIndex - 1];
            const nextProject = projects[currentIndex + 1];

            const prevContainer = document.getElementById('prev-project');
            const nextContainer = document.getElementById('next-project');

            if (prevProject) {
                prevContainer.innerHTML = `
                    <a href="project-detail.html?id=${prevProject.id}" class="work-nav-content">
                        <div class="work-nav-preview" style="background-image: url('./${prevProject.backgroundImage}')"></div>
                        <div class="work-nav-info">
                            <span class="work-nav-label"><i class="fas fa-arrow-left"></i> 上一个项目</span>
                            <h3 class="work-nav-title">${prevProject.title}</h3>
                        </div>
                    </a>
                `;
            } else {
                prevContainer.style.display = 'none';
            }

            if (nextProject) {
                nextContainer.innerHTML = `
                    <a href="project-detail.html?id=${nextProject.id}" class="work-nav-content">
                        <div class="work-nav-preview" style="background-image: url('./${nextProject.backgroundImage}')"></div>
                        <div class="work-nav-info">
                            <span class="work-nav-label">下一个项目 <i class="fas fa-arrow-right"></i></span>
                            <h3 class="work-nav-title">${nextProject.title}</h3>
                        </div>
                    </a>
                `;
            } else {
                nextContainer.style.display = 'none';
            }
        }

        document.addEventListener('DOMContentLoaded', createProjectDetail);
    </script>
    <script src="js/main.js"></script>
</body>
</html>